<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS显示-块级</title>
    <style>
      body {
        padding: 0;
        margin: 0;
      }
      .parent {
        width: 400px;
        height: 200px;
        padding: 20px;
        border: 1px solid black;
        /* 块级元素在父容器中水平居中， 左右margin设为auto */
        margin: 20px auto;
      }
      .child {
        padding: 10px;
        border: 1px solid red;
        margin: 10px;
      }
    </style>
  </head>
  <body>
    <div class="parent">
      <div class="child">内容</div>
      <div class="child" style="width: 100px; height: 100px">内容</div>
    </div>
  </body>
</html>
